package ld.service.Impl;

import ld.mapper.UserMapper;
import ld.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: Liudao
 * @Date: 2022-08-09-14:02
 * @Description:
 */
@Service
@Transactional//事务的注解
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    
    @Override
    public void bb(int inNo, int outNo, int money) {
        //转出账户
        userMapper.update(outNo,money);
        
        //出现异常会使数据丢失被破坏
//        int i = 2/0;
        //转入账户
        userMapper.update(inNo,-money);
    }
}
